import { hasChanged } from '../shared/base'
import { track, trigger } from './../shared/effect'

export const ref = <T>(v: T) => {
	const refer = {
		get value() {
			track(refer, 'value')
			return v
		},
		set value(nv: T) {
			if (hasChanged(v, nv)) {
				v = nv
				trigger(refer, 'value')
			}
		}
	}
	return refer
}
